<?php
$_user=null;
if (isset($_COOKIE['_user'])){
	$_user=$_COOKIE['_user'];
}
if(is_null($_user)){
	include("common/common.php");
	redirect("index.php");
}

include("header.php");

$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();

$sql = "SELECT * FROM `user_info`
WHERE email = '".$_user."'";
$record = $db->query_first($sql);
$db->close();

?>
<script type="text/javascript">
function subuser() 
{ 
	var ok = true;
	
	
	if(test_null(document.getElementById("uemail").value)||(document.getElementById("ureemail").value!=document.getElementById("ureemail").defaultValue)){ 
		if(!test_email(document.getElementById("uemail").value)) 
		{ 
			document.getElementById("ulemail").style.color="Red";
			ok = false; 
		}else{
			document.getElementById("ulemail").style.color="Black";
		}
		if(document.getElementById("uemail").value!=document.getElementById("ureemail").value){
			document.getElementById("ulreemail").style.color="Red";
			ok = false; 
		}else{
			document.getElementById("ulreemail").style.color="Black";
		}
	}else{
		document.getElementById("ulemail").style.color="Black";
		document.getElementById("ulreemail").style.color="Black";
	}
	if(!test_null(document.getElementById("unom").value)) 
	{ 
		document.getElementById("ulnom").style.color="Red";
		ok = false;  
	}else{
		document.getElementById("ulnom").style.color="Black";
	}
	if(!test_null(document.getElementById("uprenom").value)) 
	{ 
		document.getElementById("ulprenom").style.color="Red";
		ok = false;  
	}else{
		document.getElementById("ulprenom").style.color="Black";
	}
	if(!IsNum(document.getElementById("uzip").value)) 
	{ 
		document.getElementById("ulzip").style.color="Red";
		ok = false;  
	}else{
		document.getElementById("ulzip").style.color="Black";
	}
	if(!test_null(document.getElementById("utel").value)) 
	{ 
		document.getElementById("ultel").style.color="Red";
		ok = false;  
	}else{
		document.getElementById("ultel").style.color="Black";
	}

	if((document.getElementById("upasswd").value!=document.getElementById("upasswd").defaultValue)||(document.getElementById("urepasswd").value!=document.getElementById("urepasswd").defaultValue)){ 
		if(!test_password(document.getElementById("upasswd").value,document.getElementById("urepasswd").value)) 
		{ 
			document.getElementById("ulpasswd").style.color="Red";
			document.getElementById("ulrepasswd").style.color="Red";
			ok = false;  
		}else{
			document.getElementById("ulpasswd").style.color="Black";
			document.getElementById("ulrepasswd").style.color="Black";
		}
	}else{
		document.getElementById("ulpasswd").style.color="Black";
		document.getElementById("ulrepasswd").style.color="Black";
	}

	if(ok){
		document.getElementById("espaceform").submit();
	}
} 
</script>

<!--header end of-->
<div class="contactBg">
  <div class="contact">
    <ul>
    <?php if($_lang==FR){ ?>
      <li><?=get_local_value($_lang,"index")?>></li>
      <li><?=get_local_value($_lang,"user")?></li>
    <?php }else{?>
      <li><?=get_local_value($_lang,"user")?></li>
      <li><<?=get_local_value($_lang,"index")?></li>
    <?php }?>
    </ul>
  </div>
  <!--contact end of-->
  <div class="userForm">
  <form id="espaceform" action="comptemod.php" method="post">
     <h3 class="bottom20"><?=get_local_value($_lang,"modemail")?></h3>
     <dl>
       <dd><?=get_local_value($_lang,"realmail")?>  <span class="userColor"><?= $_user ?></span> <i style="margin-left:50px"><?php if($_lang==FR){ ?>Indiquez la nouvelle adresse email que vous souhaitez utiliser :<?php }?></i></dd>
       <dd>
	       <label id="ulemail"><?=get_local_value($_lang,"newmail")?></label> <span><input  id="uemail" name="uemail" type="text" class="input197" /></span> 
	       <label id="ulreemail"><?=get_local_value($_lang,"newmail")?></label> <span><input id="ureemail" name="ureemail" style="color:#999;" value="Confirmation" onclick="if(value==defaultValue){value='';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.style.color='#999'}" type="text" class="input197" /></span>
       </dd>
     </dl>
     
     <h3><?=get_local_value($_lang,"modpasswd")?></h3>
     <dl>
       <dd><i><?php if($_lang==FR){ ?>Indiquez le nouveau mot de passe que vous souhaitez utiliser :<?php }?></i></dd> 
       <dd>
	       <label id="ulpasswd"><?=get_local_value($_lang,"newpasswd")?></label> <span><input id="upasswd" name="upasswd" type="text" class="input197" style="color:#999;" value="5 caractères minimum" onclick="if(value==defaultValue){value='';this.type='password';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.type='text';this.style.color='#999'}" /></span> 
	       <label id="ulrepasswd"><?=get_local_value($_lang,"newpasswd")?></label> <span><input id="urepasswd" name="urepasswd" type="text" class="input197" style="color:#999;" value="Confirmation" onclick="if(value==defaultValue){value='';this.type='password';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.type='text';this.style.color='#999'}"  /></span>
       </dd>
     </dl>
     
     <h3><?=get_local_value($_lang,"modinfo")?> </h3>
     <dl>
       <dd><i></i></dd> 
       <dd style="margin-bottom:50px">
       		<table>
       			<tr>
       			<td><?=get_local_value($_lang,"sex")?> <sub>*</sub>
                    <select name="usex">
                    <?php 
                    	$sex = get_local_value($_lang,"male");
                    	if($record["sex"]==2){
                    		$sex = get_local_value($_lang,"female");
                    	}
                    ?>
                    	<option value="<?=$record["sex"]?>"><?= $sex ?></option>
						<option value="1"><?=get_local_value($_lang,"male")?></option>
						<option value="2"><?=get_local_value($_lang,"female")?></option>
					</select>
                 <td><label id="ulnom">&nbsp;&nbsp;<?=get_local_value($_lang,"nom")?></label>  <sub>*</sub><input id="unom" name="unom" type="text" value="<?= $record["nom"] ?>" class="input106" /> 
                 <td><label id="ulprenom">&nbsp;&nbsp;<?=get_local_value($_lang,"prenom")?></label>   <sub>*</sub><input id="uprenom" name="uprenom" type="text" value="<?= $record["prenom"] ?>" class="input90" /> 
                 <td><label id="ulzip">&nbsp;&nbsp;<?=get_local_value($_lang,"zip")?></label>  <sub>*</sub><input id="uzip" name="uzip" type="text" value="<?= $record["zip"] ?>" class="input106" /> 
                 <td><label id="ultel">&nbsp;&nbsp;<?=get_local_value($_lang,"tel")?></label>   <sub>*</sub><input id="utel" name="utel" type="text" value="<?= $record["tel"] ?>" class="passeInput" style="width:120px" />
      			</tr>
      		</table>
      </dd>
      <dd> 
      		<code class="fl"><sub>*</sub> <?=get_local_value($_lang,"need")?></code>   
      		<code class="fr"><input name="" type="button" onClick="subuser()" class="uesrBtn"/></code></dd>
     </dl>
  </form>
  </div>
  <!--contactForm end of-->
</div>
<!--contactBg end of-->

<?php
include("foot.php");
?>
